/*
    This file is part of libtiming.

    libtiming is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    libtiming is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with libtiming.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef TIMING_TIMEOUT_H
#define TIMING_TIMEOUT_H

class PlatformDependantTimeValue;

namespace Timing
{
	
	/**
	* Timeout
	* 
	* Usage:
	* 
	* Timing::Timeout timeout;
	* timeout.timeOutIn(0.01);
	* while(timeout.hasNotTimedOut())
	* {
	*    Timing::Timeout::sleep(0.001);
	* }
	* 
	*/
	class Timeout
	{
		
	public:
		
		/**
		* Destructor
		*/
		~Timeout();
		
		/**
		* Default Constructor
		*/
		Timeout();
		
		/**
		* Schedule timeout in a specified number of seconds
		*/
		void timeOutIn(float seconds);
		
		/**
		* Retrue TRUE if it has not timed out
		*/
		bool hasNotTimedOut() const;
		
		/**
		* Make the calling thread sleep for the specified number of seconds
		*/
		static void sleep(float seconds);
		
	private:
		
		/**
		* Time Value
		*/
		PlatformDependantTimeValue * _timeValue;
		
		/**
		* Copy Constructor should not be used
		*/
		Timeout(const Timeout & other);
		
		/**
		* Assignment Operator should not be used
		*/
		Timeout & operator= (const Timeout & rhs);
		
	};
	
}

#endif
